//
//  MainTabBar.m
//  DaoZiJinFu
//
//  Created by woker on 16/6/23.
//  Copyright © 2016年 iwoker. All rights reserved.
//

#import "MainTabBar.h"
#import "FinancialTableViewController.h"
#import "AssetViewController.h"
#import "MoreTableVC.h"
#import "LDHomePageViewController.h"
#define newImg(name) [IMAGE(name) imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]

@interface MainTabBar ()

@end

@implementation MainTabBar

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.tintColor = BLUE_COLOR;
    self.view.backgroundColor = [UIColor whiteColor];
    self.tabBar.opaque = YES;
    UIOffset offset = UIOffsetMake(0, -3);
    LDHomePageViewController *homePage = [[LDHomePageViewController alloc] init];
    UITabBarItem *homePageItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:newImg(@"首页-未点击") selectedImage:newImg(@"首页")];
    homePageItem.titlePositionAdjustment = offset;
    homePage.tabBarItem = homePageItem;
    
    FinancialTableViewController *finance = [[FinancialTableViewController alloc] init];
    UITabBarItem *financeItem = [[UITabBarItem alloc] initWithTitle:@"理财" image:newImg(@"理财-未点击") selectedImage:newImg(@"理财=点击")];
    financeItem.titlePositionAdjustment = offset;
    finance.tabBarItem = financeItem;
    
    AssetViewController *asset = [[AssetViewController alloc] init];
    UITabBarItem *assetItem = [[UITabBarItem alloc] initWithTitle:@"资产" image:newImg(@"资产-未点击") selectedImage:newImg(@"资产点击")];
    assetItem.titlePositionAdjustment = offset;
    asset.tabBarItem = assetItem;
    
    MoreTableVC *more = [[MoreTableVC alloc] init];
    UITabBarItem *moreItem = [[UITabBarItem alloc] initWithTitle:@"更多" image:newImg(@"更多-未点击") selectedImage:newImg(@"更多-点击")];
    moreItem.titlePositionAdjustment = offset;
    more.tabBarItem = moreItem;
    
    NSArray *tabBarArray = [NSArray arrayWithObjects:
                            [[MNaviCtrl alloc] initWithRootViewController:homePage],
                            [[MNaviCtrl alloc] initWithRootViewController:finance],
                            [[MNaviCtrl alloc] initWithRootViewController:asset],
                            [[MNaviCtrl alloc] initWithRootViewController:more], nil];
    [self setViewControllers:tabBarArray];
    
     //修改tabbar 的颜色
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.98];
    view.frame = self.tabBar.bounds;
    [[UITabBar appearance] insertSubview:view atIndex:0];
    [self.tabBar setBackgroundImage:[UIImage new]];
    [self.tabBar setShadowImage:IMAGE(@"渐变")];
    self.tabBar.translucent = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
